using System;
using System.Drawing;
using System.ComponentModel;
using System.ComponentModel.Design.Serialization;
using System.Reflection;
using System.Globalization;

namespace Camalon.Drawing
{
	[Serializable]
	[TypeConverter(typeof(SizeScaleConverter))]
	public struct SizeScale
	{
		private float	_width;
		private float	_height;
		
		public SizeScale( float width, float height )
		{
			_width				= width;
			_height				= height;
		}


		public SizeScale( SizeF size )
		{
			_width				= size.Width;
			_height				= size.Height;
		}


		public SizeScale( SizeScale sizeScale )
		{
			_width				= sizeScale._width;
			_height				= sizeScale._height;

		}

		#region operatoren
		public override bool Equals(object obj)
		{
			if(!( obj is SizeScale)) return false;

			return Equals((SizeScale)obj);
		}

		public bool Equals(SizeScale value)
		{
			return _width == value._width && _height == value._height;
		}

		public override int GetHashCode()
		{
			return _width.GetHashCode()^_height.GetHashCode();
		}

		public static bool operator ==(	SizeScale value1,SizeScale value2	)
		{
			return value1._width == value2._width && value1._height == value2._height;
		}

		public static bool operator !=(	SizeScale value1,SizeScale value2	)
		{
			return !(value1== value2);
		}
		#endregion operatoren


		public static SizeScale Empty
		{
			get{ return new SizeScale(0.0f,0.0f);}
		}

		[Browsable(false)]
		public bool IsEmpty
		{
			get{ return _width == 0.0f && _height == 0.0f;}
		}


		public static SizeScale Identity
		{
			get{ return new SizeScale(1.0f,1.0f);}
		}

		[Browsable(false)]
		public bool IsIdentity
		{
			get{ return _width == 1.0f && _height == 1.0f;}
		}



		[DefaultValue( 0.5f )]
		[TypeConverter(typeof(PercentConverter))]
		[RefreshProperties( RefreshProperties.All)]
		public float Width
		{
			get{ return _width;  }
			set
			{ 
				_width = value;
			}
		}


		[DefaultValue( 0.5f )]
		[TypeConverter(typeof(PercentConverter))]
		[RefreshProperties( RefreshProperties.All)]
		public float Height
		{
			get{ return _height;  }
			set
			{ 
				_height = value;
			}
		}


		[Browsable( false)]
		public SizeF Size
		{
			get{ return new SizeF(_width,_height);}
		}

		[Browsable( false)]
		public PointF Point
		{
			get{ return new PointF(_width,_height);}
		}

	}




}
